package com.xiaoxi.exam.dao;

import com.xiaoxi.exam.model.Banner;
import com.xiaoxi.exam.model.BannerExample;
import java.util.List;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Options;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.ResultMap;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

public interface BannerMapper {
    /**
     * This method was generated by MyBatis Generator.
     * This method corresponds to the database table s_business.t_banner
     *
     * @mbg.generated Mon Aug 13 18:00:14 CST 2018
     */
    long countByExample(BannerExample example);

    /**
     * This method was generated by MyBatis Generator.
     * This method corresponds to the database table s_business.t_banner
     *
     * @mbg.generated Mon Aug 13 18:00:14 CST 2018
     */
    int deleteByExample(BannerExample example);

    /**
     * This method was generated by MyBatis Generator.
     * This method corresponds to the database table s_business.t_banner
     *
     * @mbg.generated Mon Aug 13 18:00:14 CST 2018
     */
    @Update({
        "update s_business.t_banner",
        "set deleted_at = now()",
        "where id = #{id,jdbcType=BIGINT}"
    })
    int deleteByPrimaryKey(Long id);

    /**
     * This method was generated by MyBatis Generator.
     * This method corresponds to the database table s_business.t_banner
     *
     * @mbg.generated Mon Aug 13 18:00:14 CST 2018
     */
    @Select({
        "insert into s_business.t_banner (url, title, ",
        "sort, created_at, ",
        "updated_at, deleted_at)",
        "values (#{url,jdbcType=VARCHAR}, #{title,jdbcType=VARCHAR}, ",
        "#{sort,jdbcType=INTEGER}, #{createdAt,jdbcType=TIMESTAMP}, ",
        "#{updatedAt,jdbcType=TIMESTAMP}, #{deletedAt,jdbcType=TIMESTAMP})", 
        " returning id"
    })
    @Options(useGeneratedKeys=true,keyProperty="id")
    long insertReturningId(Banner record);

    /**
     * This method was generated by MyBatis Generator.
     * This method corresponds to the database table s_business.t_banner
     *
     * @mbg.generated Mon Aug 13 18:00:14 CST 2018
     */
    @Insert({
        "insert into s_business.t_banner (url, title, ",
        "sort, created_at, ",
        "updated_at, deleted_at)",
        "values (#{url,jdbcType=VARCHAR}, #{title,jdbcType=VARCHAR}, ",
        "#{sort,jdbcType=INTEGER}, #{createdAt,jdbcType=TIMESTAMP}, ",
        "#{updatedAt,jdbcType=TIMESTAMP}, #{deletedAt,jdbcType=TIMESTAMP})"
    })
    @Options(useGeneratedKeys=true,keyProperty="id")
    int insert(Banner record);

    /**
     * This method was generated by MyBatis Generator.
     * This method corresponds to the database table s_business.t_banner
     *
     * @mbg.generated Mon Aug 13 18:00:14 CST 2018
     */
    long insertSelectiveReturningId(Banner record);

    /**
     * This method was generated by MyBatis Generator.
     * This method corresponds to the database table s_business.t_banner
     *
     * @mbg.generated Mon Aug 13 18:00:14 CST 2018
     */
    int insertSelective(Banner record);

    /**
     * This method was generated by MyBatis Generator.
     * This method corresponds to the database table s_business.t_banner
     *
     * @mbg.generated Mon Aug 13 18:00:14 CST 2018
     */
    List<Banner> selectByExample(BannerExample example);

    /**
     * This method was generated by MyBatis Generator.
     * This method corresponds to the database table s_business.t_banner
     *
     * @mbg.generated Mon Aug 13 18:00:14 CST 2018
     */
    @Select({
        "select",
        "id, url, title, sort, created_at, updated_at, deleted_at",
        "from s_business.t_banner",
        "where id = #{id,jdbcType=BIGINT}"
    })
    @ResultMap("com.xiaoxi.exam.dao.BannerMapper.BaseResultMap")
    Banner selectByPrimaryKey(Long id);

    /**
     * This method was generated by MyBatis Generator.
     * This method corresponds to the database table s_business.t_banner
     *
     * @mbg.generated Mon Aug 13 18:00:14 CST 2018
     */
    int updateByExampleSelective(@Param("record") Banner record, @Param("example") BannerExample example);

    /**
     * This method was generated by MyBatis Generator.
     * This method corresponds to the database table s_business.t_banner
     *
     * @mbg.generated Mon Aug 13 18:00:14 CST 2018
     */
    int updateByExample(@Param("record") Banner record, @Param("example") BannerExample example);

    /**
     * This method was generated by MyBatis Generator.
     * This method corresponds to the database table s_business.t_banner
     *
     * @mbg.generated Mon Aug 13 18:00:14 CST 2018
     */
    int updateByPrimaryKeySelective(Banner record);

    /**
     * This method was generated by MyBatis Generator.
     * This method corresponds to the database table s_business.t_banner
     *
     * @mbg.generated Mon Aug 13 18:00:14 CST 2018
     */
    @Update({
        "update s_business.t_banner",
        "set url = #{url,jdbcType=VARCHAR},",
          "title = #{title,jdbcType=VARCHAR},",
          "sort = #{sort,jdbcType=INTEGER},",
          "created_at = #{createdAt,jdbcType=TIMESTAMP},",
          "updated_at = #{updatedAt,jdbcType=TIMESTAMP},",
          "deleted_at = #{deletedAt,jdbcType=TIMESTAMP}",
        "where id = #{id,jdbcType=BIGINT}"
    })
    int updateByPrimaryKey(Banner record);
}